define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

	    function get_date_getmassage(result){
	        if(false){
	            result='{"success":true,"msg":"","result":{"id":"2","title":"这是个标题","content":"这是推送内容","method":[{"id":1},{"id":2}],"region":[{"id":"12,2"},{"id":1}],"cat_type":[{"id":1}],"store":[{"id":2},{"id":3},{"id":4}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
	            return JSON.parse(result);
	        }else{
	            return result;
	        }
	    }

		//返回信息
		return {
			//编辑
		    get_add:function(id,title,content,method,region,cat_type,store,callback){
		    	var params = new Object();
		    	params.id = id;
		    	params.title = title;
		    	params.content = content;
		    	params.method = method;
		    	params.region = region;
		    	params.cat_type = cat_type;
		    	params.store = store;
		    	params = JSON.stringify(params);
		    	console.log(params)
		        Http.post({
                    method: 'info.message.apply',
                    updateParams:params
                },
                function(result) {
                    //函数回调
                    if(callback)
                        callback(result);
                },
                function(e) {
                	
                },
                function() {
                	
                });
		    },
		    //根据id，查找详情
		    get_massage:function(id,callback){
		        Http.post({
                    method: 'info.message.detail',
                    id:id
                },
                function(result) {//请求成功
                    if(callback)
                        callback(get_date_getmassage(result).result);
                },
                function(e) {//请求失败
                },
                function() {
                });
		    }

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Starbusiness_pushinfo_apply", factory);
});